#include "cRingReply.h"

#include <sstream>
#include <Poco/DOM/Document.h>
#include <Poco/DOM/NodeIterator.h>
#include "misc/Interface.h"
#include "misc/Debug.h"
#include "client/Client.h"
#include "client/net/cAnnounce.h"
/*********************************************************/
void cRingReply::execute()
{
	Client& c = Client::Instance();
	c.mutex.lock();
	c.ringAddr = Poco::Net::SocketAddress(addr);
	c.mutex.unlock();

	ack();
}
/*********************************************************/
std::string cRingReply::serialize() const
{
	Client& c = Client::Instance();
	std::ostringstream		ostr;
	id = c.getID();

	ostr << "<GS id='" << id << "'>";
	ostr << "<RingReply>" << addr << "</RingReply>";
	ostr << "</GS>";

	return( ostr.str() );
}
/*********************************************************/
void cRingReply::deserialize(Poco::XML::NodeIterator& it)
{
	Poco::XML::Node* pNode = it.previousNode();
	addr = pNode->innerText();
}
/*********************************************************/
std::string cRingReply::getAddr() const
{
	return addr;
}
/*********************************************************/
void cRingReply::setAddr(const std::string& a)
{
	addr = a;
}
/*********************************************************/
